<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>仪器详细信息</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">仪器详细信息</h1>
		</header>
		<div class="mui-content">
			<div class="details_con">
				<div class="clum">
					<span class="name">DIV-BU</span>
					<span  class="txt"  id="diviBu"></span>
				</div>
				<div class="clum">
					<span class="name">仪器型号</span>
					<span class="txt" id="instrumentNo"></span>
				</div>
				<div class="clum">
					<span class="name">序列号</span>
					<span class="txt" id="instrumentSerialNumber"></span>
				</div>
				<!-- <div class="clum">
					<span class="name">SLA</span>
					<span class="txt" id="sla"></span>
				</div> -->
				<div class="clum">
					<span class="name">培训名额</span>
					<span class="txt" id="trainQuota"></span>
				</div>
				<!-- <div class="clum">
					<span class="name">合同详细信息</span>
					<span class="txt" id="contract"></span>
				</div> -->
				<div class="clum">
					<span class="name">安装日期</span>
					<span class="txt" id="installationDate"></span>
				</div>
				<div class="clum">
					<span class="name">省份-城市</span>
					<span class="txt" id="province"></span>
				</div>
				<div class="clum_arr">
					<span class="name_arr">上门地址</span>
					<span  class="txt_arr" id="homeAddress"></span>
				</div>
				<div class="clum">
					<span class="name">仪器状态</span>
					<span class="txt" id="instrumentStatus"></span>
				</div>
				<div class="clum">
					<span class="name">状态备注</span>
					<span class="txt" id="statusRemark"></span>
				</div>
				<div class="clum">
					<span class="name">MaterialCode</span>
					<span  class="txt"  id="materialcode"></span>
				</div>
				<div class="clum">
					<span class="name">LifeCycleStatus</span>
					<span  class="txt"  id="lifecycle"></span>
				</div>
				<div class="clum">
					<span class="name">CFDA</span>
					<span  class="txt"  id="cfda"></span>
				</div>
				<div class="clum">
					<span class="name">品牌</span>
					<span  class="txt"  id="brand"></span>
				</div>
				<div class="clum">
					<span class="name">约定服务范围</span>
					<span  class="txt"  id="serviceRange"></span>
				</div>
			</div>
		
			<div class="btn_box" style="overflow: auto;" id="anniu" style="display: none;">
				<span class="fl red one" onclick="chakanqd()">查看仪器配置清单</span>
			</div>
		
			<div style="height: 50px;"></div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			var urlFile = ""
			
			var ServiceNoticeId
			var serviceNo
			
			// 仪器详情用带过去
			var trainQuota
			var installationDate
			var cfda
			
			(function($, doc) {
				$.init();

				

				$.plusReady(function() {
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					 // 获取上一个页面传过来的参数并显示到页面
					 ServiceNoticeId = self.ServiceNoticeId;
					 serviceNo = self.serviceNo;
					 
					 trainQuota = self.trainQuota;
					 installationDate = self.installationDate;
					 cfda = self.cfda;
					 
					 console.log("ServiceNoticeId:"+ServiceNoticeId+"	serviceNo:"+serviceNo)
					 
					 // 获取详情的方法
					 getDetails();
					 
					
					 
				});
				
				
				
			}(mui, document));
			
			function chakanqd(){
				 plus.runtime.openURL(urlFile);
			}
			
			// 获取详情的方法
			function getDetails(){
				ajaxGet(BASE_URL + "cc/instrument/getServiceInstrument", {
					"ServiceNoticeId": ServiceNoticeId
				}, function(data) {
					console.log(JSON.stringify(data))
					if (data.code == 200) {
						if(data.data!=""){
							h("#diviBu").html(data.data[0].diviBu);
							if(data.data[0].instrumentNo==undefined || data.data[0].instrumentNo==""){
								h("#instrumentNo").html("无");
							}else{
								h("#instrumentNo").html(data.data[0].instrumentNo);
							}
							if(data.data[0].instrumentSerialNumber==undefined || data.data[0].instrumentSerialNumber==""){
								h("#instrumentSerialNumber").html("无");
							}else{
								h("#instrumentSerialNumber").html(data.data[0].instrumentSerialNumber);
							}
							if(data.data[0].sla==undefined || data.data[0].sla==""){
								h("#sla").html("无");
							}else{
								h("#sla").html(data.data[0].sla);
							}
							
							h("#trainQuota").html(trainQuota);
			
							if(data.data[0].contract==undefined || data.data[0].contract==""){
								h("#contract").html("无");
							}else{
								h("#contract").html(data.data[0].contract);
							}
							
							h("#installationDate").html(installationDate);
			
							if(data.data[0].instrumentStatus==undefined || data.data[0].instrumentStatus==""){
								h("#instrumentStatus").html("无");
							}else{
								h("#instrumentStatus").html(data.data[0].instrumentStatus);
							}
							if(data.data[0].statusRemark==undefined || data.data[0].statusRemark==""){
								h("#statusRemark").html("无");
							}else{
								h("#statusRemark").html(data.data[0].statusRemark);
							}
							if(data.data[0].materialcode==undefined || data.data[0].materialcode==""){
								h("#materialcode").html("无");
							}else{
								h("#materialcode").html(data.data[0].materialcode);
							}
							if(data.data[0].lifecycle==undefined || data.data[0].lifecycle==""){
								h("#lifecycle").html("无");
							}else{
								h("#lifecycle").html(data.data[0].lifecycle);
							}
			
							h("#cfda").html(data.data[0].cfda);
								
							if(data.data[0].brand==undefined || data.data[0].brand==""){
								h("#brand").html("无");
							}else{
								h("#brand").html(data.data[0].brand);
							}
							if(data.data[0].serviceRange==undefined || data.data[0].serviceRange==""){
								h("#serviceRange").html("无");
							}else{
								h("#serviceRange").html(data.data[0].serviceRange);
							}

							if(data.data[0].homeAddress==undefined || data.data[0].homeAddress==""){
								h("#homeAddress").html("无");
							}else{
								h("#homeAddress").html(data.data[0].homeAddress);
							}
							
							var instrumentId = data.data[0].instrumentId==undefined?"":data.data[0].instrumentId;
							getInstrumentFile(instrumentId);
							
						}
			
					}

				}, function(errorMsg) {
					console.log(JSON.stringify(errorMsg))
				});

				ajaxGet(BASE_URL + "cc/notice/getDaiZhiPaiNoticeDetail", {
					"ServiceNoticeId": ServiceNoticeId
				}, function(data) {
					console.log(JSON.stringify(data))
					if (data.code == 200) {
						if(data.data!=""){

							var province = "";
							if(data.data.province!=undefined && data.data.province!=""){
								province = data.data.province
							}
							if(data.data.city!=null && data.data.city!=""){
								if(province!=""){
									province = province +"-"+data.data.city
								}else{
									province = data.data.city
								}
							}
							h("#province").html(province);
						}

					}
				}, function(errorMsg) {
					console.log(JSON.stringify(errorMsg))
				});
			}
			
			// 查询仪器配置清单
			function getInstrumentFile(instrumentId){
				h("#anniu").hide()
				ajaxGet(BASE_URL + "cc/instrument/getInstrumentFile", {
					"instrumentCode": instrumentId,
					"serviceNo": serviceNo,
					"enginnerId": app.getUser().enginnerId
				}, function(data) {
					console.log("仪器配置清单"+JSON.stringify(data))
					if (data.code == 200) {
						if(data.data.code == 200){
							if(data.data.data.status=='1'){
								// var html = ''
								// html += '<div class="btn_box" style="overflow: auto;">'
								// 	html += '<span class="fl red one" id="chakanqd">查看仪器配置清单</span>'
								// html += '</div>';
								
								h("#anniu").show()
								
								urlFile = data.data.data.record[0].url;
								
								// var dtask = plus.downloader.createDownload(data.data.data.record[0].url, {}, function(d, status) {
								// 	if(status == 200) {
								// 		var fileUrl = d.filename;
								// 		plus.runtime.openFile(fileUrl, {}, function(e) {
								// 			plus.nativeUI.toast('打开失败');
								// 		});
								// 	} else {
								// 		plus.nativeUI.toast('打开失败');
								// 	}
								// });
								// // 执行下载任务，再打开
								// dtask.start();
							}
						}
					}
				}, function(errorMsg) {
					console.log(JSON.stringify(errorMsg))
				});
			}
			
		</script>
		<!-- js代码 end -->

	</body>

</html>
